package com.lxl.hadoop.flowsum;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @Author lixilin
 * @Date 2021/12/5 19:59
 * @Description
 */
public class FlowMapper extends Mapper<LongWritable, Text,LongWritable,FlowBean> {
    LongWritable phone = new LongWritable();
    FlowBean flowBean = new FlowBean();
    protected void map(LongWritable key, Text value,
                       Context context) throws IOException, InterruptedException {
        String line = value.toString();
        String[] words = line.split("\t");
        phone.set(Long.valueOf(words[1]));
        flowBean.setUpFlow(Long.valueOf(words[words.length-3]));
        flowBean.setDownFlow(Long.valueOf(words[words.length -2]));
        context.write(phone,flowBean);
    }
}
